<%#-- copyright
OpenProject is a project management system.
Copyright (C) 2012-2015 the OpenProject Foundation (OPF)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.

OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2013 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

See doc/COPYRIGHT.rdoc for more details.

++#%>

<div class="modal-wrapper--content">
  <%= labelled_tabular_form_for(@user, url: account_register_path, html: { class: 'form -wide-labels' }) do |f| %>

    <%= back_url_hidden_field_tag %>
    <%= error_messages_for :user %>

    <div class="modal--header">
      <%= homescreen_user_avatar %>
      <h2><%= I18n.t('onboarding.welcome') %></h2>
    </div>
    <div class="modal--main">
      <h2><%= t(:label_register) %></h2>
      <section class="form--section">
        <% if @user.auth_source_id.nil? %>
          <div class="form--field -wide-label">
            <% if Setting.email_login? %>
              <%= email_field(f) %>
            <% else %>
              <%= login_field(f) %>
            <% end %>
          </div>
        <% end %>
        <div class="form--field -wide-label">
          <%= f.text_field :firstname, required: true %>
        </div>

        <div class="form--field -wide-label">
          <%= f.text_field :lastname,  required: true %>
        </div>

        <% if registration_show_email? %>
          <div class="form--field -wide-label">
            <%= email_field(f) %>
          </div>
        <% end %>

        <%= call_hook :view_account_register_after_basic_information, f: f %>

        <%= render partial:     'customizable/field',
                   collection:  @user.custom_field_values.select { |v|
                                  v.editable? || v.required?
                                },
                   as:          :value,
                   locals:      { form: f, wide_labels: true } %>

        <br/><br/>
        <% if @user.change_password_allowed? %>
          <div class="form--field -wide-label -reduced-margin">
            <%= f.password_field :password,
                                 required: true,
                                 size: 25,
                                 autocomplete: 'off' %>
            <div class="form--field-instructions">
              <%= password_complexity_requirements %>
            </div>
          </div>
          <div class="form--field -wide-label">
            <%= f.password_field :password_confirmation,
                                 required: true,
                                 size: 25,
                                 autocomplete: 'off'  %>
          </div>
        <% end %>
      </section>

        <%= styled_button_tag l(:button_create), class: '-highlight -with-icon icon-checkmark' %>

        <%= render partial: 'account/auth_providers', locals: { omniauth_title: I18n.t('account.signup_with_auth_provider'), wide: true } %>
    </div>
    <div class="modal--footer">
      <%= render partial: 'account/footer' %>
    </div>
  <% end %>
</div>
